import  {createRouter,createWebHashHistory} from  "vue-router"
import HomeView from "../views/HomeView2.vue"

//配置信息中需要页面的相关配置

const routes=[
    {
        path :'/',
        name:"home",
        component:HomeView
    },
    {
        path:"/about",
        name:"about",
        //重定向
        redirect:"/about/us",
        component:() => import('../views/AboutView2.vue'),
        children:[
            {
                //二级导航路径不要加/
                path:"us",
                component:() =>import("../views/about_sub/AboutUs.vue")
            },
            {
                //二级导航路径不要加/
                path:"info",
                component:() =>import("../views/about_sub/AboutInfo.vue")
            }
        ]
    },
    {
        path:"/news",
        name:"news",
        //这是异步加载方式
        component:() => import('../views/NewsView.vue')
    },
    {
        path:"/newsdetails/:name",
        name:"newsdetails",
        //这是异步加载方式
        component:() => import('../views/NewsDetailsView.vue')
    }
]


const router = createRouter({
        
/**
 * createWebHashHistory 
 *   home:http://localhost:8080/#/
 * 
 * 
 * 原理: a标签锚点连接
 */

/**
 * createWebHistory
 * 
 *  home:http://localhost:8080/
 * 此种方式,需要后台配合做重定向，否则会出现404问题
 */

        history:createWebHashHistory(),
        routes
})

export default router;